
{{template "base.html" .}}

{{define "content"}}
<!--操作按钮模板-->
<script type="text/html" id="barDemo">
    <a class="layui-btn layui-btn-xs" lay-event="accept">详情</a>
    <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="refuse">发消息</a>
</script>
<!--操作按钮模板end-->
<div id="Booking-box">
    <div class="Booking-box-textRow layui-row layui-col-space20">
        <div  class="layui-col-md12 Booking-box-text">
            <h1>学生心理测试数据分析</h1>
        </div>
    </div>
    <div class="Booking-box-row layui-row layui-col-space20" style="width: 100%; overflow-x: auto;">
        <div id="Booking-box-left" class="layui-col-md12">
            <table id="bookingTable-1" lay-filter="demo"></table>
        </div>
    </div>
    <script>
        layui.use('table', function(){
            var table = layui.table;
            table.render({
                elem: '#bookingTable-1',
                url: 'http://127.0.0.1:8080/teacher/getScl90', //数据接口
                method: 'get', // 使用 GET 请求方式
                page: true, // 开启分页
                limit: 10,
                limits: [10, 15, 20],
                cellMinWidth: 80,
                height: 'full',
                cols: [[
                    { field: 'id', title: '编号', width: 88, sort: true, align: 'center',hide: true },
                    { field: 'userId', title: '编号', width: 88, sort: true, align: 'center',hide: true },
                    { field: 'StudentName', title: '学生',fixed: 'left', width: 80, align: 'center'},
                    { field: 'somatization',sort :true, title: '躯体化',width: 90,  align: 'center',templet: function(d) {return customRender(d.somatization);} },
                    { field: 'obsessiveCompulsive',sort :true, title: '强迫症状',width: 100, align: 'center',templet: function(d) {return customRender(d.obsessiveCompulsive);} },
                    { field: 'interpersonalSensitivity',sort :true, title: '人际关系敏感',width: 130, align: 'center',templet: function(d) {return customRender(d.interpersonalSensitivity);} },
                    { field: 'depression',sort :true, title: '抑郁', align: 'center',templet: function(d) {return customRender(d.depression);} },
                    { field: 'anxiety',sort :true, title: '焦虑', align: 'center' ,templet: function(d) {return customRender(d.anxiety);}},
                    { field: 'hostile',sort :true, title: '敌对', align: 'center' ,templet: function(d) {return customRender(d.hostile);}},
                    { field: 'terror',sort :true, title: '恐怖', align: 'center' ,templet: function(d) {return customRender(d.terror);}},
                    { field: 'bigotry',sort :true, title: '偏执', align: 'center' ,templet: function(d) {return customRender(d.bigotry);}},
                    { field: 'psychotic',sort :true, title: '精神病性', width: 100,align: 'center',templet: function(d) {return customRender(d.psychotic);} },
                    { field: 'other',sort :true, title: '其他', align: 'center' ,templet: function(d) {return customRender(d.other);}},
                    { field: 'sum',sort :true, title: '总分', align: 'center' },
                    { field: 'average',sort :true, title: '总均分',width: 90, align: 'center' },
                    { field: 'feminine',sort :true, title: '阴性项目', width: 100,align: 'center' },
                    { field: 'masculineSum',sort :true, title: '阳性总分',width: 100, align: 'center' },
                    { field: 'masculine',sort :true, title: '阳性项目',width: 100, align: 'center' },
                    { field: 'masculineAge',sort :true, title: '阳性症状均分',width: 130, align: 'center' },
                    { field: 'right', title: '操作', templet:'#barDemo', width: 150, fixed: 'right',align:'center'},
                ]],
            });
        });
    </script>
<script>
    function customRender (d){
        if (d<=2){
            return '<span>无</span>'
        }else if (d>2 && d<3){
            return '<span style="color: green;">轻度</span>'
        }else if (d>=3&& d<4){
            return '<span style="color: orange;">中度</span>'
        }else if (d>=4){
            return '<span style="color: #c00;">重度</span>'
        }
    }
</script>
    <script>
        layui.use('table', function(){
            var table = layui.table;
            table.on('tool(demo)', function(obj){
                var data = obj.data;
                if(obj.event === 'refuse'){
                    $(location).attr("href","/teacher/client/msg/"+data.userId)
                }else if (obj.event === 'accept'){
                    $(location).attr("href","/teacher/getScl90/"+data.id)
                }
            });
        })
    </script>
</div>
<style>
    #Booking-box{
        padding: 5%;
        height: 500px;
    }
    .Booking-box-row,#Booking-box-left,#Booking-box-right{
        height: 100%;
    }
    #Booking-box-left{

    }
    #Booking-box-right{

    }
</style>
{{end}}
